﻿<Window x:Class="Freshome.m.vws.Recipe"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:f="clr-namespace:Freshome.m.vws"
      Style="{StaticResource smaller}" MaxWidth="900" MaxHeight="600"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="菜谱配料" WindowStartupLocation="CenterOwner">
    <Window.Resources>
        <f:Bool2Visible x:Key="b2v" />
    </Window.Resources>
    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Save" CanExecute="Save_CanExecute" Executed="Save_Executed" />
    </Window.CommandBindings>
    <Grid x:Name="topanel">
        <Grid.RowDefinitions>
            <RowDefinition></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="200"></ColumnDefinition>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
            <ColumnDefinition MinWidth="200"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <DockPanel LastChildFill="True">
            <ListBox DockPanel.Dock="Bottom" Margin="2" MinHeight="120" ItemsSource="{Binding Path=Steps}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Path=Planum}" Width="20"></TextBlock>
                            <TextBlock Text="{Binding Path=Notes}" TextWrapping="Wrap" MinWidth="200" MaxWidth="300"></TextBlock>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            <Border DockPanel.Dock="Left" Margin="2" BorderThickness="1" BorderBrush="SteelBlue" CornerRadius="3" Width="200">
                <Image Source="{Binding Path=Bimage}" Stretch="None"></Image>
            </Border>
            <StackPanel>
                <TextBlock Text="{Binding Path=Name}" FontWeight="Bold"></TextBlock>
                <TextBlock Text="{Binding Path=Notes}" TextWrapping="Wrap"></TextBlock>
            </StackPanel>
        </DockPanel>
        <DockPanel LastChildFill="True" Grid.Row="1">
            <Button x:Name="btr" IsCancel="True" DockPanel.Dock="Left">关闭(_C)</Button>
            <TextBlock HorizontalAlignment="Right">配料单是在制作菜谱时生成的。</TextBlock>
        </DockPanel>
        <GridSplitter Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Width="3" VerticalAlignment="Stretch" HorizontalAlignment="Center" ShowsPreview="True"></GridSplitter>
        <StackPanel Grid.Column="2">
            <DataGrid x:Name="dgj" ItemsSource="{Binding Path=Majors}" IsReadOnly="{Binding Readonly}" CanUserAddRows="False" CanUserDeleteRows="False">
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding Path=Raw.Parentitle}" Header="主料名称" MinWidth="100" MaxWidth="200" IsReadOnly="True"/>
                    <DataGridCheckBoxColumn Binding="{Binding Path=Prime}" Header="主选" MinWidth="30" MaxWidth="50"></DataGridCheckBoxColumn>
                    <DataGridTextColumn Binding="{Binding Path=Notes}" Header="主料使用说明" MinWidth="200" MaxWidth="500" ToolTipService.ToolTip="0 - 50个字符"/>
                </DataGrid.Columns>
            </DataGrid>
            <DataGrid x:Name="dgi" ItemsSource="{Binding Path=Minors}" IsReadOnly="{Binding Readonly}" CanUserAddRows="False" CanUserDeleteRows="False">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="佐料名称" MinWidth="100" MaxWidth="200" Binding="{Binding Path=Raw.Parentitle}" IsReadOnly="True" />
                    <DataGridTextColumn Binding="{Binding Path=Notes}" Header="佐料使用说明" MinWidth="200" MaxWidth="500" ToolTipService.ToolTip="0 - 50个字符"/>
                </DataGrid.Columns>
            </DataGrid>
        </StackPanel>
        <DockPanel  Grid.Row="1" Grid.Column="2" LastChildFill="True">
            <Button Command="ApplicationCommands.Save" Visibility="{Binding Path=Enabled, Converter={StaticResource b2v}}" DockPanel.Dock="Right">保存(_S)</Button>
            <TextBlock>此处不可添加或删除佐料或主料的配料说明。</TextBlock>
        </DockPanel>
    </Grid>
</Window>
